package com.ruoyi.aitcommon.config;

import javax.annotation.PostConstruct;

import com.ruoyi.aitcommon.utils.VersionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.ruoyi.aitcommon.utils.LogUtils;

@Component
public class AITConfig {
//	使用静态变量，这样配置可以被工具类使用
	private static String name;
	private static String version;
	private static String port;
	private static String path;

	private static String uploadPath;

	@PostConstruct
	void init() {
		String msg="配置文件读取:\r\n系统名称:[%s] 系统版本:[%s] 启动端口:[%s] 启动路径:[%s]";
        msg=String.format(msg, AITConfig.getName(),AITConfig.getVersion(),AITConfig.getPort(),AITConfig.getPath());
        LogUtils.debug(msg);
	}
	public static String getUploadPath(){return getUserDir()+"\\fileserver";}
	public static String getCodeVersion(){return VersionUtils.getCodeVersion();}
	public static String getUserDir(){ return System.getProperty("user.dir");}
	public static String getPath() {
		return path;
	}
	@Value("${ait.path}")
	public void setPath(String path) {
		AITConfig.path = path;
	}
	public static String getPort() {
		return port;
	}
	@Value("${server.port}")
	public void setPort(String port) {
		AITConfig.port=port;
	}
	public static String getName() {
		return name;
	}
//	set方法不能是静态，这样spring加载bean时可以自动赋值
	@Value("${ait.name}")
	public void setName(String name) {
		AITConfig.name = name;
	}
	public static String getVersion() {
		return version;
	}
	@Value("${ait.version}")
	public void setVersion(String version) {
		AITConfig.version = version;
	}

}
